﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.admin.templates.label
{
    public partial class selectfreelabel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                GetList();
            }
        }
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        protected void GetList()
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            YXShop.BLL.Templates.FreeLabel data = new YXShop.BLL.Templates.FreeLabel();
            ChangeHope.DataBase.DataByPage dataPage = data.GetListAll();
            //第一步先添加表头
            table.AddHeadCol("5%", "序号");
            table.AddHeadCol("50%", "标签名称");
            table.AddHeadCol("45%", "标签描述");
            table.AddRow();
            //添加表的内容
            if (dataPage.DataReader != null)
            {
                int curpage = ChangeHope.WebPage.PageRequest.GetInt("pageindex");
                if (curpage < 0)
                {
                    curpage = 1;
                }
                int count = 0;
                while (dataPage.DataReader.Read())
                {
                    count++;
                    string No = (15 * (curpage - 1) + count).ToString();
                    table.AddCol(No);
                    table.AddCol(string.Format("<a href='#' onclick=\"javascript:ReturnValue('{0}','{1}');\">{0}</a>", dataPage.DataReader["free_name"].ToString(), dataPage.DataReader["type_id"].ToString()));
                    table.AddCol(string.Format("{0}", dataPage.DataReader["free_description"].ToString()));
                    table.AddRow();
                }
            }
            string view = table.GetTable() + dataPage.PageToolBar;
            dataPage.Dispose();
            dataPage = null;
            this.Literal1.Text = view;
        }

        protected void lbSearch_Click(object sender, EventArgs e)
        {
            GetList();
        }
    }
}
